import { IPSDBSysPortletPart } from './ipsdbsys-portlet-part';
import { PSDBPortletPartImpl } from './psdbportlet-part-impl';
import { IPSLanguageRes } from '../../res/ipslanguage-res';
import { IPSSysCss } from '../../res/ipssys-css';
import { IPSSysImage } from '../../res/ipssys-image';
import { IPSSysPFPlugin } from '../../res/ipssys-pfplugin';
import { IPSSysUniRes } from '../../security/ipssys-uni-res';

export class PSDBSysPortletPartImpl extends PSDBPortletPartImpl implements IPSDBSysPortletPart {
  get codeName(): string {
    return this.M.codeName;
  }

  get height(): number {
    return this.M.height;
  }

  protected pssyscss: IPSSysCss | null = null;

  getPSSysCss(): IPSSysCss | null {
    if (this.pssyscss != null) return this.pssyscss;
    const value = this.M.getPSSysCss;
    if (value == null) {
      return null;
    }
    this.pssyscss = this.getPSModel4('res.IPSSysCss', value, 'getPSSysCss') as IPSSysCss;
    return this.pssyscss;
  }

  get psSysCss(): IPSSysCss | null {
    return this.getPSSysCss();
  }

  getPSSysCssMust(): IPSSysCss {
    const value = this.getPSSysCss();
    if (value == null) {
      throw new Error('未指定界面样式');
    }
    return value;
  }

  protected pssysimage: IPSSysImage | null = null;

  getPSSysImage(): IPSSysImage | null {
    if (this.pssysimage != null) return this.pssysimage;
    const value = this.M.getPSSysImage;
    if (value == null) {
      return null;
    }
    this.pssysimage = this.getPSModel4('res.IPSSysImage', value, 'getPSSysImage') as IPSSysImage;
    return this.pssysimage;
  }

  get psSysImage(): IPSSysImage | null {
    return this.getPSSysImage();
  }

  getPSSysImageMust(): IPSSysImage {
    const value = this.getPSSysImage();
    if (value == null) {
      throw new Error('未指定系统图片');
    }
    return value;
  }

  protected pssyspfplugin: IPSSysPFPlugin | null = null;

  getPSSysPFPlugin(): IPSSysPFPlugin | null {
    if (this.pssyspfplugin != null) return this.pssyspfplugin;
    const value = this.M.getPSSysPFPlugin;
    if (value == null) {
      return null;
    }
    this.pssyspfplugin = this.getPSModel4('res.IPSSysPFPlugin', value, 'getPSSysPFPlugin') as IPSSysPFPlugin;
    return this.pssyspfplugin;
  }

  get psSysPFPlugin(): IPSSysPFPlugin | null {
    return this.getPSSysPFPlugin();
  }

  getPSSysPFPluginMust(): IPSSysPFPlugin {
    const value = this.getPSSysPFPlugin();
    if (value == null) {
      throw new Error('未指定前端扩展插件');
    }
    return value;
  }

  protected pssysunires: IPSSysUniRes | null = null;

  getPSSysUniRes(): IPSSysUniRes | null {
    if (this.pssysunires != null) return this.pssysunires;
    const value = this.M.getPSSysUniRes;
    if (value == null) {
      return null;
    }
    this.pssysunires = this.getPSModel4('security.IPSSysUniRes', value, 'getPSSysUniRes') as IPSSysUniRes;
    return this.pssysunires;
  }

  get psSysUniRes(): IPSSysUniRes | null {
    return this.getPSSysUniRes();
  }

  getPSSysUniResMust(): IPSSysUniRes {
    const value = this.getPSSysUniRes();
    if (value == null) {
      throw new Error('未指定系统统一资源');
    }
    return value;
  }

  get portletType(): 'LIST' | 'CHART' | 'VIEW' | 'HTML' | 'TOOLBAR' | 'ACTIONBAR' | 'CUSTOM' | 'APPMENU' | 'CONTAINER' | 'RAWITEM' {
    return this.M.portletType;
  }

  get timer(): number {
    return this.M.timer != null ? this.M.timer : 0;
  }

  get title(): string {
    return this.M.title;
  }

  protected titlepslanguageres: IPSLanguageRes | null = null;

  getTitlePSLanguageRes(): IPSLanguageRes | null {
    if (this.titlepslanguageres != null) return this.titlepslanguageres;
    const value = this.M.getTitlePSLanguageRes;
    if (value == null) {
      return null;
    }
    this.titlepslanguageres = this.getPSModel4('res.IPSLanguageRes', value, 'getTitlePSLanguageRes') as IPSLanguageRes;
    return this.titlepslanguageres;
  }

  get titlePSLanguageRes(): IPSLanguageRes | null {
    return this.getTitlePSLanguageRes();
  }

  getTitlePSLanguageResMust(): IPSLanguageRes {
    const value = this.getTitlePSLanguageRes();
    if (value == null) {
      throw new Error('未指定抬头语言资源对象');
    }
    return value;
  }

  get cls(): string {
    return 'PSDBSysPortletPartImpl';
  }

  instanceof(cls: string): boolean {
    if (cls == 'control.dashboard.IPSDBSysPortletPart') return true;
    return super.instanceof(cls);
  }
}
